home *** CD-ROM | disk | FTP | other *** search
/ Suzy B Software 2 / Suzy B Software CD-ROM 2 (1994).iso / extras / programm / gemfsc20 / gemfsc20.lzh / GNUGEM27 / AESAPPL.C next >
C/C++ Source or Header  |  1993-03-24  |  3KB  |  135 lines

  1. /*
  2.  *    Aes application library interface
  3.  *
  4.  *    appl_init      initialize a session and return application id.
  5.  *    appl_exit      terminate a session.
  6.  *    appl_read      read bytes from a message pipe
  7.  *    appl_write      write bytes to a message pipe
  8.  *        appl_find      find the application id of another application.
  9.  *    appl_tplay      play back a piece of a recorded session
  10.  *    appl_trecord  record a set of user interactions with aes
  11.  *
  12.  *    ++jrb    bammi@cadence.com
  13.  *    modified: mj -- ntomczak@vm.ucs.ualberta.ca
  14.  */
  15. #include <stddef.h>
  16. #include "common.h"
  17.  
  18. #ifdef __DEF_ALL__
  19.  
  20. #define L_appl_ini
  21. #define L_appl_rea
  22. #define L_appl_wri
  23. #define L_appl_fin
  24. #define L_appl_tpl
  25. #define L_appl_tre
  26. #define L_appl_exi
  27.  
  28. #endif /* __DEF_ALL__ */
  29.  
  30.  
  31. #ifdef L_appl_ini
  32.  
  33. /* initialize a session
  34.  *    returns apid
  35.  */
  36. int appl_init(void)
  37. {
  38.     int retval;
  39.     void bzero(void *, size_t);
  40.  
  41.     /* clear all binding arrays */
  42.     /* other binding arrays are synonyms for the stuff */
  43.     /* listed below - c.f. "common.h"              */
  44.  
  45.     bzero(_contrl,    CNTRLMAX*sizeof(short));
  46.     bzero(_intin,    INTINMAX*sizeof(short));
  47.     bzero(_intout,    INTOUTMAX*sizeof(short));
  48.     bzero(_ptsin,    2*PTSINMAX*sizeof(short));
  49.     bzero(_ptsout,    2*PTSOUTMAX*sizeof(short));
  50.     bzero(_global,    GLOBMAX*sizeof(short));
  51.  
  52.     retval = __aes__(AES_CONTROL_ENCODE(10, 0, 1, 0));
  53.  
  54.     gl_ap_version = _global[0];
  55.     gl_apid = _global[2];
  56.     return retval;
  57. }
  58. #endif /* L_appl_ini */
  59.  
  60.  
  61. #ifdef L_appl_rea
  62.  
  63. /*    read message from pipe */
  64. int appl_read(int ApId, int Length, void *ApPbuff)
  65. {
  66.     _int_in[0] =  ApId;
  67.     _int_in[1] = Length;
  68.     _addrin[0] = ApPbuff;
  69.     return __aes__(AES_CONTROL_ENCODE(11, 2, 1, 1));
  70. }
  71. #endif /* L_appl_rea */
  72.  
  73. #ifdef L_appl_wri
  74.  
  75. /*    write message to pipe */
  76. int appl_write(int ApId, int Length, void *ApPbuff)
  77. {
  78.     _int_in[0] =  ApId;
  79.     _int_in[1] = Length;
  80.     _addrin[0] = ApPbuff;
  81.     return __aes__(AES_CONTROL_ENCODE(12, 2, 1, 1));
  82. }
  83. #endif /* L_appl_wri */
  84.  
  85.  
  86. #ifdef L_appl_fin
  87.  
  88. /* find application id */
  89. int appl_find(char *Name)
  90. {
  91.     _addrin[0] = Name;
  92.     return __aes__(AES_CONTROL_ENCODE(13, 0, 1, 1));
  93. }
  94. #endif /* L_appl_fin */
  95.  
  96. #ifdef L_appl_tpl
  97.  
  98. /*    Play back Num actions from a recorded journal Mem at
  99.  *    speed Scale (1 <= Scale <= 10,000)
  100.  */
  101. int appl_tplay(void *Mem, int Num, int Scale)
  102. {
  103.     _int_in[0] =   Num;
  104.     _int_in[1] =   Scale;
  105.     _addrin[0] =  Mem;
  106.     return __aes__(AES_CONTROL_ENCODE(14, 2, 1, 1));
  107. }
  108. #endif /* L_appl_tpl */
  109.  
  110. #ifdef L_appl_tre
  111.  
  112. /* journal user interaction with aes in Mem upto Count actions
  113.  * returns actual # of actions recorded
  114.  */
  115. int appl_trecord(void *Mem, int Count)
  116. {
  117.     _int_in[0] =  Count;
  118.     _addrin[0] = Mem;  /* sizeof(Mem) == 6 * Count bytes */
  119.     return __aes__(AES_CONTROL_ENCODE(15, 1, 1, 1));
  120. }
  121. #endif /* L_appl_tre */
  122.  
  123. #ifdef L_appl_exi
  124.  
  125. /* terminate a session
  126.  * returns 0 on error    >0 no error
  127.  */
  128. int appl_exit(void)
  129. {
  130.     return __aes__(AES_CONTROL_ENCODE(19, 0, 1, 0));
  131. }
  132. #endif /* L_appl_exi */
  133.  
  134. /* - eof - */
  135.